
// 引入路由 npm install vue-router@3.6.5
import VueRouter from 'vue-router'
import Vue from 'vue'

import Find from '@/views/Find'
import My from '@/views/My'
import Friend from '@/views/Friend'
import NotFind from '@/views/NotFind'
import Home from '@/views/navigation/Home'
import Search from '@/views/navigation/Search'

Vue.use(VueRouter)

// 创建路由对象
const router = new VueRouter({
  mode: 'history',  // mode类型: hash类型(默认),history类型; history表示地址栏不懈怠#
  routes: [
    {
      path: '/find',
      component: Find
    },
    {
      path: '/my',
      component: My
    },
    {
      path: '/friend',
      component: Friend
    },
    // 查询参数传参
    // { path: '/home', component: Home },
    // { path: '/search', component: Search },
    // 动态路由传参
    { path: '/', redirect: '/home' }, // 路由重定向
    { path: '/home/', component: Home },
    { name: 'search', path: '/search/:words?', component: Search },   // ?表示参数可选,不加表示参数是必传
    { path: '*', component: NotFind }, // 当所有路由未被命中,就会命中*路由
  
  ],
  // link自定义高亮类名
  linkActiveClass: 'active', // 配置模糊匹配的类名
  linkExactActiveClass: 'exact-active'  // 配置精确匹配的类名
})

export default router